home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / utility / uwserver.zip / uwserver.tar / h / uw_fd.h < prev    next >
C/C++ Source or Header  |  1991-01-25  |  1KB  |  56 lines

  1. /*
  2.  *    uw_fd - file-descriptor/select data
  3.  *
  4.  * Copyright 1986 by John D. Bruner.  All rights reserved.  Permission to
  5.  * copy this program is given provided that the copy is not sold and that
  6.  * this copyright notice is included.
  7.  */
  8.  
  9. #ifndef UW_FD
  10. #define    UW_FD
  11.  
  12. #include "uw_param.h"
  13.  
  14. /*
  15.  * If FD_SET and friends aren't defined in <sys/types.h>, then we
  16.  * provide simple definitions here.
  17.  */
  18. #ifndef FD_SET
  19. #define    FD_SET(n,p)    ((p)->fds_bits[0] |= (1 << (n)))
  20. #define    FD_CLR(n,p)    ((p)->fds_bits[0] &= ~(1 << (n)))
  21. #define    FD_ISSET(n,p)    ((p)->fds_bits[0] & (1 << (n)))
  22. #define    FD_ZERO(p)    ((p)->fds_bits[0] = 0)
  23. #define    FD_SETSIZE    (NBBY*sizeof(long))
  24. #endif
  25.  
  26. /*
  27.  * We use file descriptors for several different things.  "fdmap" associates
  28.  * a file descriptor number with its use.
  29.  */
  30. typedef enum {                /* file descriptor type */
  31.     FDT_NONE,            /*    not in use */
  32.     FDT_DATA,            /*    data connection for window */
  33.     FDT_CTL,            /*    control connection for window */
  34.     FDT_MAC,            /*    tty line which talks to Mac */
  35.     FDT_UDSOCK,            /*    UNIX-domain datagram socket */
  36.     FDT_ISSOCK,            /*    Internet-domain stream sock */
  37.     FDT_DEBUG,            /*    debugging use */
  38.     FDT_OTHER            /*    other uses */
  39. } fdtype_t;
  40.  
  41. struct fdmap {
  42.     fdtype_t    f_type;        /* file descriptor type */
  43.     struct window    *f_win;        /* associate window (if any) */
  44. };
  45.  
  46. struct selmask {
  47.     struct fd_set    sm_rd;
  48.     struct fd_set    sm_wt;
  49.     struct fd_set    sm_ex;
  50. };
  51.  
  52. extern struct fdmap fdmap[FD_SETSIZE];
  53. extern fildes_t nfds;
  54. extern struct selmask selmask[2];
  55. #endif
  56.